import request from '@/utils/request.js';

function params(obj) {
    let result = ''
    let item
    for (item in obj) {
        if (obj[item] && String(obj[item])) {
            result += `&${item}=${obj[item]}`
        }
    }
    if (result) {
        result = '?' + result.slice(1)
    }
    return result
}

export async function reqSample(params) {
    return request('/sample/' + params.current + '/' + params.limit, {
        method: 'GET',
    })
}

export async function changeSample(params) {
    return request('/sample', {
        method: 'PUT',
        data: params
    })
}


export async function sortSample(param) {
    const data = params(param)
    return request(`/sample/condition${data}`, {
        method: 'GET',
    })
}

export async function bindSampleid(params) {
    return request('/maps/add', {
        method: 'PUT',
        data: params
    })
}

export async function deleteSample(params) {
    console.log(params)
    return request(`/sample/${params}`, {
        method: 'delete',
        data: params
    })
}

export async function addSample(param) {
    // const data = params(param)
    return request('/sample', {
        method: 'POST',
        data: param
    })
}

export async function updataFibsem(params) {
    return request(`/fib-sem/add`, {
        method: 'POST',
        data: params
    })
}

export async function updataQemscan(params) {
    return request('/qemscan', {
        method: 'POST',
        data: params
    })
}

//Qemscan的界面
export async function qemscanView(params) {
    return request('/qemscan/' + params, {
        method: 'GET'
    })
}

//Qemscan的开始任务
export async function qemscanStart(params) {
    return request('/qemscan/qemscan', {
        method: 'POST',
        data: params
    })
}

//qemscan的展示
export async function qemscanDisplay(params) {
    return request('/maps/display/' + params, {
        method: 'GET'
    })
}